package com.relatev.minecraft.UWantRestart.Bukkit;

import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;

public class CommandManager {
    
    public static boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        sender.sendMessage("§r------§aUWantRestart§r------");
        if (args.length == 0) {
            sender.sendMessage("§bhttps://www.relatev.com/forum.php?mod=viewthread&tid=2504");
            sender.sendMessage("§c/" + label + " help 查阅帮助");
            return true;
        }
        if (args[0].equalsIgnoreCase("help")) {
            sender.sendMessage("§ehelp 查阅帮助");
            sender.sendMessage("§elist 自动重启条件表");
            sender.sendMessage("§erestart <秒数> (提示信息) 在多少秒后重启");
        }
        if (sender.hasPermission("UWantRestart.admin")) {
            if (args[0].equalsIgnoreCase("list")) {
                sender.sendMessage("§b条件表：");
                sender.sendMessage("" + ConfigManager.RestartConditions);
            }
            if (args[0].equalsIgnoreCase("restart")) {
                switch (args.length) {
                    case 1:
                        BKRestartTasker.restart("§c服务器即将重启...§a请稍后上线!");
                    case 2:
                        BKRestartTasker.restart("§c服务器即将重启...§a请稍后上线!", Integer.parseInt(args[1]));
                    case 3:
                        BKRestartTasker.restart(args[2].replaceAll("&", "§"), Integer.parseInt(args[1]));
                }
                sender.sendMessage("§a任务已提交");
            }
        }
        return true;
    }
}
